#ifndef PROJECTDB_H
#define PROJECTDB_H
#include <QtSql/qsql.h>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
//#include <QSqlDatabase>
//#include <QSqlQuery>
#include <QVariant>
class ProjectDB
{
public:
    ProjectDB();

private:
        double m_dblBCBC;		// 比差补偿
        double m_dblJCBC;		// 角差补偿

public:
    int newTest();
    void addNewRecord(int, QString, QString,QString, QString);
    void addData2Record(int, QString,QString, QString, QString, QString);

    static QSqlDatabase db;
    static bool isOpen;

//    QSqlQuery qWcxx;
//    QSqlQuery qWcdata;
    QSqlQuery openWcxx();
    QSqlQuery openWcxxforSql(QString);
    QSqlQuery openWcdata(QString);
    QSqlQuery openWcdataforSj(QString);
    int getWcxxCountForSql(QString);
    int getWcxxCount();
    void delWc(QString);
    void DelAll();

/*
    QSqlQuery qWCBC;        //误差补偿表
    QSqlQuery qXTCS;        //系统参数表
    QSqlQuery qDefaultAQ;  //质量分析窗口默认值
    QSqlQuery query;        //默认值
*/
public:
    /*
        double XTJC(){double get();}
        double BCBC(){double get();}
        double JCBC(){double get();}
        bool IsApplyWCBC(){bool get();}
        double Zero_BFB(){double get();}
        */
public:
        bool OpenDB();		// 打开数据库
        bool CloseDB();
public:
        // 保存更改
        bool Save(QString TableName);
        bool Save();
public:
        // 获得正在测试点的误差补偿值
        QString getParameter(QString sParaName);
        bool getParameterBool(QString sParaName);
        // 根据误差测量百分表，决定补偿值
        void getBuChang(int iBFB);
        // 根据是否为标准端口决定9-2的采样速率
        int getSmpRate92(bool bIsStandard);
        void setSmpRate92(int value){SmpRate92=value;};
        // 打开测量点表
        bool OpenCLD_RS(void);
        // 保存测量点表
        bool SaveCLD_RS(void);
        bool OpenCompanyRS(void);
        bool SaveCompanyRS(void);
        bool OpenBZQJ_RS(void);
        bool SaveBZQJ_RS(void);

        void getXTCS();
        void setXTCS();
        void setHGQ_Channel(int value){HGQ_Channel=value;}
        void setTBFS(int value){TBFS=value;}
        void setBZXZ(int value){BZXZ=value;}
        void setBCXZ(int value){BCXZ=value;}
        void setBZXDY(QString value){bzxdy=value;}
        void setBCXDY(QString value){bcxdy=value;}
        void setbfbzero(QString value){bfbzero=value;}
        void setrepeat(int value){repeat=value;}
        void setCTPT(int value){mCTPT=value;}
        void setTbsx(int value){m_Tbsx=value;}
        void setSysXs(QString value){sysXs=value;}
        void setSysBc(QString value){sysBc=value;}
        void setSysJc(QString value){sysJc=value;}
        void setCTJD(QString value){m_CTJD=value;}
        void setPTJD(QString value){m_PTJD=value;}
        void setBjcs(int value){m_Bjcs=value;}
        void setCyys(int value){m_Cyys=value;}
        void setCyfs(QString value){m_Cyfs=value;}
        void setMac(QString value){m_Mac=value;}
        void setSuanfa(int value){m_iSuanfa=value;}
        void setEDYC(QString value)
        {
            if (mCTPT==0)
                edyc_dl=value;
            else
                edyc_dy=value;
        }
        /*
        double getBCBC(){return m_BCBC;};
        double getJCBC(){return m_JCBC;};
        double getBCBC1(){return m_BCBC1;};
        double getJCBC1(){return m_JCBC1;};
        double getBCBC2(){return m_BCBC2;};
        double getJCBC2(){return m_JCBC2;};
        double getBCBC3(){return m_BCBC3;};
        double getJCBC3(){return m_JCBC3;};
        double getBCBC4(){return m_BCBC4;};
        double getJCBC4(){return m_JCBC4;};
        void setBCBC(double value){m_BCBC=value;};
        void setJCBC(double value){m_JCBC=value;};
        */
        void setsystemBC(int i,double value1,double value2)
        {
            if(i==0)
            {m_BCBC=value1;m_JCBC=value2;}
            else if(i==1)
            {m_BCBC1=value1;m_JCBC1=value2;}
            else if(i==2)
            {m_BCBC2=value1;m_JCBC2=value2;}
            else if(i==3)
            {m_BCBC3=value1;m_JCBC3=value2;}
            else if(i==4)
            {m_BCBC4=value1;m_JCBC4=value2;}
            else if(i==5)
            {m_BCBC5=value1;m_JCBC5=value2;}
            else if(i==6)
            {m_BCBC6=value1;m_JCBC6=value2;}
            else if(i==7)
            {m_BCBC7=value1;m_JCBC7=value2;}
            else if(i==8)
            {m_BCBC8=value1;m_JCBC8=value2;}
            else if(i==9)
            {m_BCBC9=value1;m_JCBC9=value2;}
        }

        QString insertWcxx(QString,QString,QString,QString);
        void insertWcdata(QString,QString,QString,QString,QString,QString,QString);
        void updateWcdata(QString,QString,QString,QString,QString,QString,QString);
        void updateWcxxDate(QString,QString);
        int HGQ_Channel;
        int TBFS;
        int BZXZ;
        int BCXZ;
        int SmpRate92;
        QString bfbzero;
        int repeat;
        QString bzxdy;
        QString bcxdy;
        int mCTPT;
        QString m_Cyfs;
        QString m_Mac;
        QString edyc_dl;
        QString edyc_dy;
        QString sysXs;
        QString sysBc;
        QString sysJc;
        double m_BCBC;		// 比差补偿
        double m_JCBC;		// 角差补偿
        double m_BCBC1;		// 比差补偿
        double m_JCBC1;		// 角差补偿
        double m_BCBC2;		// 比差补偿
        double m_JCBC2;		// 角差补偿
        double m_BCBC3;		// 比差补偿
        double m_JCBC3;		// 角差补偿
        double m_BCBC4;		// 比差补偿
        double m_JCBC4;		// 角差补偿
        double m_BCBC5;		// 比差补偿
        double m_JCBC5;		// 角差补偿
        double m_BCBC6;		// 比差补偿
        double m_JCBC6;		// 角差补偿
        double m_BCBC7;		// 比差补偿
        double m_JCBC7;		// 角差补偿
        double m_BCBC8;		// 比差补偿
        double m_JCBC8;		// 角差补偿
        double m_BCBC9;		// 比差补偿
        double m_JCBC9;		// 角差补偿
        int m_Tbsx;
        QString m_CTJD;
        QString m_PTJD;
        int m_Bjcs;
        int m_Cyys;
        int m_iSuanfa;
};

#endif // PROJECTDB_H
